
package com.fire.eyes.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.fire.eyes.dao.FireDangrousResouceMapper;
import com.fire.eyes.model.FireDangrousResouceModel;
import com.fire.eyes.response.DresDTO;
import com.fire.eyes.service.IFireDangrousResouceService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.plugins.Page;

import java.util.List;
import java.util.Map;

/**
 * 消防危险源Service
 *
 * @author Matthew
 * @Date 2019-01-17 20:48
 */
@Service
public class FireDangrousResouceServiceImpl extends ServiceImpl<FireDangrousResouceMapper, FireDangrousResouceModel> implements IFireDangrousResouceService {

	private static final Logger LOGGER = LoggerFactory.getLogger(FireDangrousResouceServiceImpl.class);

	@Autowired
	private FireDangrousResouceMapper fireDangrousResouceMapper;

	@Override
	public FireDangrousResouceModel selectOne(FireDangrousResouceModel entity) {
		return fireDangrousResouceMapper.selectOne(entity);
	}

	@Override
	public List<FireDangrousResouceModel> selectList(FireDangrousResouceModel model) {
		return fireDangrousResouceMapper.selectListByModel(model);
	}

	@Override
	public Page<FireDangrousResouceModel> selectPage(int currentPage, int pageSize, Wrapper<FireDangrousResouceModel> wrapper) {
		return selectPage(new Page<FireDangrousResouceModel>(currentPage, pageSize), wrapper);
	}

	@Override
	public Page<Map<String, Object>> selectMapsPage(int currentPage, int pageSize, Wrapper<FireDangrousResouceModel> wrapper) {
		return selectMapsPage(new Page<FireDangrousResouceModel>(currentPage, pageSize), wrapper);
	}

	@Override
	public List<DresDTO> selectListBySupervisorid(String supervisor, Integer page, Integer pagesize) {
		if (page != null && page.intValue() != 999 && page.intValue() != 0 && pagesize != null && pagesize.intValue() != 999 && pagesize.intValue() != 0) {
			return fireDangrousResouceMapper.selectListBySupervisorid(supervisor, (page - 1) * pagesize, pagesize);
		}
		return fireDangrousResouceMapper.selectListBySupervisorid(supervisor, null, null);
	}

}
